package com.shop.controller;

import com.shop.annotation.RequiresPermissionsDesc;
import com.shop.pojo.DtsFootprint;
import com.shop.service.DtsFootprintService;
import com.shop.util.ResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName AdminFootprintControllet
 * @Author xiao宋
 * @Date 18:24  2022/10/16
 * @Version 1.0
 * @Description TODO
 */
@Slf4j
@RestController
@RequestMapping("/admin/footprint")
public class AdminFootprintController {
    @Autowired
    DtsFootprintService footprintService;

    /**
     * 会员足迹
     *
     * @param page
     * @param limit
     * @param sort
     * @param order
     * @param userId
     * @param goodsId
     * @return
     */
    @RequiresPermissions("admin:user:list")
    @RequiresPermissionsDesc(menu = {"系统管理", "用户管理"}, button = "会员足迹查询")
    @GetMapping("/list")
    public Object footprint(
            @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
            @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit,
            @RequestParam(value = "sort", required = false, defaultValue = "add_time") String sort,
            @RequestParam(value = "order", required = false, defaultValue = "desc") String order,
            Integer userId, Integer goodsId
    ) {
        log.debug("显示会员足迹分页方法");
        log.debug("前端传过来的每页条数：{}，第几页：{}", page, limit);
        Map<String, Object> data = footprintService.findByPage(page, limit, sort, order, userId, goodsId);
        log.debug("会员足迹分页方法显示完毕");

        return ResponseUtil.ok(data);
    }
}



